<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'test2.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script type="text/javascript" src="<%=path%>/js/jquery-1.7.2.js"></script>
	<script type="text/javascript" src="<%=path%>/js/jquery-jtemplates.js"></script>
	<script type="text/javascript">  
   		$(function() {  
		    //初始化JSON数据  
		    var data = {  
	     		name: '用户列表',  
	     		list_id: '编号89757',  
	     		table: [  
			      	{id: 1, name: 'Rain', age: 22, mail: 'cssrain@domain.com'},  
			      	{id: 2, name: '皮特', age: 24, mail: 'cssrain@domain.com'},  
			      	{id: 3, name: '卡卡', age: 20, mail: 'cssrain@domain.com'},  
			      	{id: 4, name: '戏戏', age: 26, mail: 'cssrain@domain.com'},  
			      	{id: 5, name: '一揪', age: 25, mail: 'cssrain@domain.com'}  
	     		]  
	    	};  
	    	// 附上模板  
	    	$("#result1").setTemplateElement("template");  
	    	// 给模板加载数据  
	    	$("#result1").processTemplate(data);  
	   });   
   	   
   		function formatDate(date){
   			return "2015-12-18";
   		}
	</script>
  </head>
  
  <body>
  
  	<!-- 输出元素 -->  
	<div id="result1" ></div> 


    <!-- 模板内容 -->  
	<textarea id="template" style="display:none">  
   		<strong>{$T.name} : {$T.list_id}</strong>  
		<table>  
        	<tr>  
		      	<th>编号</th>  
		      	<th>姓名</th>  
                <th>年龄</th>  
		      	<th>邮箱</th>  
   			</tr>
		    {#foreach $T.table as record begin=1}
		    <tr bgcolor="{#cycle values=['#AAAAAA','#CCCCCC']}">  
		      	<td>{$T.record.id}</td>  
		      	<td>{$T.record.name}</td>  
                <td>{formatDate($T.record.age)}</td>  
		      	<td>{$T.record.mail}</td>  
		    </tr>
   			{#/for}
		</table>  
	</textarea>
  </body>
</html>
